import request from '@/utils/request.js'

/**
 * 获取Album列表
 */
export const getAlbumPage = (params) => request.get('/album/page', { params })

/**
 * 保存或更新Album
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const saveOrUpdateAlbum = (data) => request.post('/album', data)

/**
 * 获取Album的歌曲列表
 */
export const getAlbumSongs = (id, name) =>
  request.get(`/album/get/songs/${id}`, {
    params: {
      name
    }
  })

/**
 * 获取歌单可用的歌曲
 */
export const getAlbumAvailableSongs = (name) =>
  request.get(`/album/available/songs`, { params: { name } })

/**
 * 批量删除Album
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteBatchAlbum = (data) => request.delete('/album', { data })

/**
 * 添加歌曲到歌单
 * @param data : {
 *  id:number 歌单id
 *  songIds:Arrays<number> 歌曲id集合
 * }
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addAlbumSongs = (data) => request.post('/album/add/songs', data)

/**
 * 删除歌曲从歌单
 * @param data : {
 *  id:number 歌单id
 *  songIds:Arrays<number> 歌曲id集合
 * }
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deleteAlbumSongs = (data) =>
  request.post('/album/remove/songs', data)
